switch (state) {
  case 0:
    LOAD(linkUrl);
  case 1:
    // Loop through document's images and return the image
    // whose attribute value matches the regular expression.
    // Note that regular expression's '\' characters must be escaped ('\\')
    // in attrValuePattern because it's a string.
    var attrName = "src";
    var attrValuePattern = "^http://www\\.example\\.net/.+$";
    var re = new RegExp(attrValuePattern);
    var images = document.images;
    for (var i = 0; i < images.length; i++)
      if (re.test(images[i][attrName]))
        RETURN(images[i].src);
    break;
}